package zwp.example.demo1;

import zwp.example.pojo.Student;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Demo7ListDistinct {

    public static void main(String[] args) {
        //应派单台区经理信息（能够获取到1-应派单台区经理数
        // 2-当日所有的台区经理信息
        // 3-筛选掉派单经理后，可以获取到未派单台区经理信息）
        List<Student> list1 = new ArrayList<>();
        list1.add(Student.builder().id(1).age("1").userName1("1").build());
        list1.add(Student.builder().id(2).age("2").userName1("2").build());
        list1.add(Student.builder().id(3).age("2").userName1("3").build());
        list1.add(Student.builder().id(4).age("4").userName1("4").build());
        list1.add(Student.builder().id(5).age("5").userName1("5").build());
        //已派单工单信息（能够获取到已派单台区经理明细,）
        List<Student> list2 = new ArrayList<>();
        list2.add(Student.builder().age("1").userName2("1").userName1("1").build());
        list2.add(Student.builder().age("1").userName2("1").userName1("2").build());
        list2.add(Student.builder().age("2").userName2("2").userName1("2").build());
        list2.add(Student.builder().age("2").userName2("2").userName1("1").build());
        list2.add(Student.builder().age("3").userName2("3").userName1("3").build());


        List<Student> list3 = new ArrayList<>();
        int size = list3.size();
        Student student = new Student();
        student.setId(list3.size());
        System.out.println(size);
//        Map<String, Set<String>> groupedStudents = new HashMap<>();
//        for (Student student : list2) {
//            groupedStudents.putIfAbsent(student.getAge(),new HashSet<>());
//            groupedStudents.get(student.getAge()).add(Stream.of(student.getUserName1(),student.getUserName2()))
//        }

//        // Collect all userNames from list2 (both userName1 and userName2)
//        Set<String> userNamesInList2 = list2.stream()
//                .flatMap(student -> Stream.of(student.getUserName1(), student.getUserName2()))
//                .collect(Collectors.toSet());
//        System.out.println(userNamesInList2);
//        System.out.println("------------------------------");
//        // Filter list1 for entries where userName1 exists in userNames from list2
//        List<Student> filteredList = list1.stream()
//                .filter(student -> userNamesInList2.contains(student.getUserName1()))
//                .collect(Collectors.toList());
//        System.out.println(filteredList);
//        System.out.println("------------------------------");
//        // Output for verification
//        filteredList.forEach(student -> System.out.println("ID: " + student.getId() + ", UserName1: " + student.getUserName1()));
//        System.out.println("------------------------------");
//        List<Student> userNamesNotInList2 = list1.stream()
//                .filter(student -> !userNamesInList2.contains(student.getUserName1()))
//                .collect(Collectors.toList());
//        System.out.println(userNamesNotInList2);
    }
}
